﻿Public Class CrackClave
    Private xCadCrack As String = "!ã1ka_Ãq&r%)#<s¿i?¡$@Âx:{b§u0(¥ ‼->.} "
    Private xCadEquiv As String = "ABCDEFGHIJKLMNLOPQRSTUVWXYZ0123456789 "
    Function Encryptar(ByVal Text As String) As String
        Dim resul As String = ""
        Try

            Dim i As Integer
            Dim flag As Boolean = True
            For i = 1 To Text.Length
                Dim letra As String = Mid(Text, i, 1)
                Dim pos As Integer = InStr(xCadEquiv, letra)
                If flag = True Then
                    pos = pos + 19
                    If pos > 37 Then
                        pos = pos - 37
                    End If
                    flag = False
                Else
                    pos = pos - 19
                    If pos < 1 Then
                        pos = pos + 37
                    End If
                    flag = True
                End If
                resul = resul & xCaracter(2) & Mid(xCadCrack, pos, 1) & xCaracter(1)
            Next i
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try
        Return resul
    End Function
    Function DesEncryptar(ByVal Passw As String) As String
        Dim resul As String = ""
        Try
            Dim i As Integer
            Dim flag As Boolean = True
            If Passw.Length = 0 Then
                Passw = "BLANCOERROR123" ' CUANDO EL PASSWORD ES ESTA EN BLANCO LA CONTRASEÑA ES QRQS
            End If
            For i = 1 To Passw.Length
                Dim letra As String = Mid(Passw, i + 2, 1)
                Dim pos As Integer = InStr(xCadCrack, letra)
                If flag = True Then
                    pos = pos - 19
                    If pos < 1 Then
                        pos = pos + 37
                    End If
                    flag = False
                Else
                    pos = pos + 19
                    If pos > 37 Then
                        pos = pos - 37
                    End If
                    flag = True
                End If
                resul = resul + Mid(xCadEquiv, pos, 1)
                i = i + 3
            Next i

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try
        Return resul
    End Function
    Private Function xCaracter(ByVal p As Byte) As String
        Dim resul As String = ""
        Try
            Dim xPOS As Integer = (Rnd() * 10) * 3 + 10
            xPOS = xPOS - (Rnd() * 10)
            If xPOS < 1 Then
                xPOS = xPOS + (Rnd() * 10)
            End If
            resul = Mid(xCadCrack, xPOS, p)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try
        Return resul
    End Function
End Class
